import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

public class T {
    public static void main(String[] args) {
        Set<Book> set = new HashSet<>();
        set.add(new Book(1,"《java书籍》"));
        set.add(new Book(1,"《java书籍》"));
        set.add(new Book(1,"《java书籍》"));
        System.out.println(set.size());

        Book b1 = new Book(1,"《java书籍》");
        Book b2 = new Book(12,"《java书籍》");
        System.out.println(b1.hashCode());
        System.out.println(b2.hashCode());

        String s11="通话";
        System.out.println(s11.hashCode());
        String s22="重地";
        System.out.println(s22.hashCode());

    }
}

class Book{
    private int id;
    private String name;

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    public Book(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public Book() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return id == book.id && Objects.equals(name, book.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    public void setName(String name) {
        this.name = name;
    }
}
